package com.shop.dao;

import java.util.List;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.shop.idao.IOrderItemDao;
import com.shop.model.OrderItem;

public class OrderItemDaoImpl extends HibernateDaoSupport implements IOrderItemDao {
	public void addOrderItem(OrderItem orderItem) {
		this.getHibernateTemplate().save(orderItem);
	}

	public void deleteOrderItem(int order_item_id) {
	}

	public void modifyOrderItem(int order_item_id) {
	}

	public List queryOrderItem() {
		List orderItemList = this.getHibernateTemplate().find("from OrderItem");
		return orderItemList;
	}

	@Override
	public void deleteByProductId(int product_id) {
		Session session = this.getSession();
		session.createSQLQuery("delete from orderitem where product_id='" + product_id + "'").executeUpdate();
		session.close();
	}
}